package moon.core.instruction;

import moon.core.expression.Expr;

/** 
 * Assignment instructions. 
 * An entity is associated to the return of an expression.
 * 

 * @see moon.core.instruction.Instr
 * @see moon.core.expression.Expr
 * @see moon.core.entity.Entity
 * 
 * 
 * @author <a href="mailto:rmartico@ubu.es">Ra&uacute;l Marticorena</a>
 */
@SuppressWarnings("serial")
public abstract class AssignmentInstr extends Instr {

	/** 
	 * Expression that takes the value.
     */    
    private Expr leftSide;  
        
    /** 
     * Expression that returns an entity value.
     */    
    private Expr rightSide;
    
    /** 
     * Constructor.
     * 
     * @param exprLeftSide expression left side
     * @param exprRigthSide expression right side
     * @param line line
     * @param column column
     */
    public AssignmentInstr(Expr exprLeftSide, Expr exprRigthSide, int line, int column) {
        super(line,column);
        this.setLeftSide(exprLeftSide);
        this.setRighSide(exprRigthSide);
    }
    
    /** 
     * Gets the entity assigned to entity returned by the expression.
     * 
     * @return expression
     * @see #setLeftSide
     */    
    public Expr getLeftSide() {
        return this.leftSide;
    }
    
    /** 
     * Updates the entity left side of the assignment.
     * 
     * @param expr expression
     * @see #getLeftSide
     */    
    public void setLeftSide(Expr expr) {
        this.leftSide = expr;
    }
    
    /** 
     * Expression that returns an entity assigned the left side.
     * 
     * @param pExpr left side expression
     * @see #getRighSide
     */    
    public void setRighSide(Expr pExpr){
        this.rightSide = pExpr;
    }
    
    /** 
     * Gets the expression on the right side of the assignment.
     * 
     * @return expression
     * @see #setRighSide
     */    
    public Expr getRighSide(){
        return this.rightSide;
    }

} // Assignment Instruction
